#include<stdio.h> 
#include<conio.h> 
#include<ctype.h> 
#include<string.h> 
int n1,n2,n; 
int s1[1000],s2[1000]; 
char s[1000]; 
void nhan(void); 
void main() 
{ 
  int i; 
 clrscr(); 
 printf("chuong trinh nhan so lon\n"); 
 printf("so thu nhat: "); 
 gets(s); 
 n2=strlen(s)-1; 
 for (i=0;i<=n1;i++) s2[n2-i]=s[i]-48; 
 printf("\ntich la: "); 
 nhan(); 
 getch(); 
} 
void nhan(void) 
{ 
 int nho,i,bac,tich,j; 
 int tong[1000]={0},tg[1000]={0}; 
 int nmax,ntg; 
 n=0;bac=1;tich=1;nho=0;nmax=0; 
 for (j=0;j<=n2;j++) 
     { 
      bac=j; 
      for (i=0;i<=n1;i++) 
         { 
          tich=s1[i]*s2[j]+nho; 
          tg[i+bac]=tich%10; 
          nho=tich/10; 
         } 
      ntg=n1+bac; 
      while (nho) 
           { 
        ntg++; 
        tg[ntg]=nho%10; 
        nho/=10; 
           } 
      for (i=bac;i<=ntg;i++) 
         { 
          tong[i]+=tg[i]+nho; 
          nho=tong[i]/10; 
           tong[i]%=10; 
         } 
      while (nho) 
           { 
         ntg++; 
         tong[ntg]=tong[ntg]+nho%10; 
         nho=nho/10; 
           } 
      if (ntg>nmax) nmax=ntg; 
     } 
 for (i=nmax;i>=0;i--) printf("%d",tong[i]); 
}
getch();
